﻿using System;
using UnityEngine;
/// <summary>
/// 持续伤害区域
/// This class will apply continuous damage to the Player as long as it stay inside the trigger on the same object
/// </summary>
public class DamageZone : MonoBehaviour
{
    private RubyController controller;
    //碰撞体首次进入时调用一次
    private void OnTriggerEnter2D(Collider2D other)
    {
        controller = other.GetComponent<RubyController>();
    }
    //碰撞体停留在区域内时每帧调用	持续区域效果
    void OnTriggerStay2D(Collider2D other)
    {
        if (controller != null)
        {
            //the controller will take care of ignoring the damage during the invincibility time.
            controller.ChangeHealth(-1);
        }
    }
    //碰撞体离开区域时调用一次	离开区域检测
    private void OnTriggerExit2D(Collider2D other)
    {
        
    }
}